<?php
$file=$_GET["file"];
$url=exec("/usr/local/etc/youtube-dl/yt_dl --user-agent Firefox -g " .escapeshellarg($file));
//file_put_contents("/usr/local/etc/youtubelink.txt", $url);
$rCURL = curl_init();

curl_setopt($rCURL, CURLOPT_URL, $url);
curl_setopt($rCURL, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($rCURL, CURLOPT_HEADER, 0);
curl_setopt($rCURL, CURLOPT_RETURNTRANSFER, 0);

$aData = curl_exec($rCURL);

curl_close($rCURL);
header ("Content-type: video/mp4");
//header ("Content-Length: 200000"); 
echo $url;
//file_put_contents("/usr/local/etc/youtubelink.txt", $url);
//preg_match('/youtube\.com\/(v\/|watch\?v=|embed\/)([\w\-]+)/', $file, $match);
//$id = $match[2];
//require 'Youtube.php';

//$youtube = new Zarkiel\Media\Youtube();
//$links = $youtube->getDownloadLinks($id);
////echo $id;

//$l = array_shift($links);
//$m = array_shift($l);
//echo $m;
///$first = current(array_filter($links));
///echo $links['MP4']['High Quality - 1280x720'];
///echo $first;
